fix some more XPaths

Andrew Cantino 10 years ago
parent
commit
ebe302492d
3 changed files with 10 additions and 10 deletions
  1. 5 5
      db/seeds.rb
  2. 3 3
      spec/lib/utils_spec.rb
  3. 2 2
      spec/models/agent_spec.rb

+ 5 - 5
db/seeds.rb

@@ -31,9 +31,9 @@ unless user.agents.where(:name => "XKCD Source").exists?
31 31
                            'mode' => "on_change",
32 32
                            'expected_update_period_in_days' => 5,
33 33
                            'extract' => {
34
-                               'url' => { 'css' => "#comic img", 'attr' => "src" },
35
-                               'title' => { 'css' => "#comic img", 'attr' => "alt" },
36
-                               'hovertext' => { 'css' => "#comic img", 'attr' => "title" }
34
+                               'url' => { 'css' => "#comic img", 'value' => "@src" },
35
+                               'title' => { 'css' => "#comic img", 'value' => "@alt" },
36
+                               'hovertext' => { 'css' => "#comic img", 'value' => "@title" }
37 37
                            }
38 38
                        }).save!
39 39
 end
@@ -47,8 +47,8 @@ unless user.agents.where(:name => "iTunes Trailer Source").exists?
47 47
                            'type' => "xml",
48 48
                            'expected_update_period_in_days' => 5,
49 49
                            'extract' => {
50
-                               'title' => { 'css' => "item title", 'text' => true},
51
-                               'url' => { 'css' => "item link", 'text' => true}
50
+                               'title' => { 'css' => "item title", 'value' => ".//text()"},
51
+                               'url' => { 'css' => "item link", 'value' => ".//text()"}
52 52
                            }
53 53
                        }).save!
54 54
 end

+ 3 - 3
spec/lib/utils_spec.rb

@@ -22,8 +22,8 @@ describe Utils do
22 22
 
23 23
       Utils.unindent("Hello\n  I am indented").should == "Hello\n  I am indented"
24 24
 
25
-      a = "        Events will have the fields you specified.  Your options look like:\n\n            {\n      \"url\": {\n        \"css\": \"#comic img\",\n        \"attr\": \"src\"\n      },\n      \"title\": {\n        \"css\": \"#comic img\",\n        \"attr\": \"title\"\n      }\n    }\"\n"
26
-      Utils.unindent(a).should == "Events will have the fields you specified.  Your options look like:\n\n    {\n      \"url\": {\n\"css\": \"#comic img\",\n\"attr\": \"src\"\n      },\n      \"title\": {\n\"css\": \"#comic img\",\n\"attr\": \"title\"\n      }\n    }\""
25
+      a = "        Events will have the fields you specified.  Your options look like:\n\n            {\n      \"url\": {\n        \"css\": \"#comic img\",\n        \"value\": \"@src\"\n      },\n      \"title\": {\n        \"css\": \"#comic img\",\n        \"value\": \"@title\"\n      }\n    }\"\n"
26
+      Utils.unindent(a).should == "Events will have the fields you specified.  Your options look like:\n\n    {\n      \"url\": {\n\"css\": \"#comic img\",\n\"value\": \"@src\"\n      },\n      \"title\": {\n\"css\": \"#comic img\",\n\"value\": \"@title\"\n      }\n    }\""
27 27
     end
28 28
   end
29 29
 
@@ -114,4 +114,4 @@ describe Utils do
114 114
       cleaned_json.should include("<\\/script>")
115 115
     end
116 116
   end
117
-end
117
+end

+ 2 - 2
spec/models/agent_spec.rb

@@ -751,8 +751,8 @@ describe AgentDrop do
751 751
         url: 'http://xkcd.com/',
752 752
         mode: 'on_change',
753 753
         extract: {
754
-          url: { css: '#comic img', attr: 'src' },
755
-          title: { css: '#comic img', attr: 'alt' },
754
+          url: { css: '#comic img', value: '@src' },
755
+          title: { css: '#comic img', value: '@alt' },
756 756
         },
757 757
       },
758 758
       schedule: 'every_1h',